package com.zhangwei.liwushuo.fragment;

import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.viewpagerindicator.TabPageIndicator;
import com.zhangwei.liwushuo.R;
import com.zhangwei.liwushuo.adapter.VpiPagerAdapter;

import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.ViewById;
import org.androidannotations.annotations.res.IntArrayRes;
import org.androidannotations.annotations.res.StringArrayRes;

import java.util.ArrayList;

/**
 * <item>精选</item>109
 * <item>穿搭</item>110
 * <item>礼物</item>112
 * <item>美护</item>113
 * <item>美食</item>118
 * <item>鞋包</item>117
 * <item>娱乐</item>120
 */
@EFragment(R.layout.fragment_home)
public class HomeFragment extends BaseFragment {

    @ViewById
    TabPageIndicator homeTbi;
    @ViewById
    ViewPager homeVpi;


    @StringArrayRes(R.array.home_tab_names)
    String[] tabNames;
    @IntArrayRes(R.array.home_tab_index)
    int[] tabIndex;

    private ArrayList<Fragment> fragments = new ArrayList<>();

    @Override
    public void beforeInject() {
        for (int i = 0; i < tabIndex.length; i++) {
            fragments.add(HomeItemsFragment_.builder().channelsIndex(tabIndex[i]).build());
        }
    }

    @Override
    public void initView() {
        VpiPagerAdapter vpiAdapter = new VpiPagerAdapter(getChildFragmentManager(), fragments, tabNames);
        homeVpi.setAdapter(vpiAdapter);
        homeTbi.setViewPager(homeVpi);
    }

    @Override
    public void initData() {

    }
}
